home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
System Booster
/
System Booster.iso
/
Systemmonitors
/
RSys
/
RSysSrc.lha
/
RSysModify.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-19
|
24KB
|
1,080 lines
/*
***************************************************************************
*
* Datei:
* RSysModify.c
*
* Inhalt:
*
* --- Globale Routinen ---
*
* int CheckWindow ( struct Window *findwin );
* void CountAssocObjects ( struct Task *task , int *wins , int *scrs , int *ports );
* void ModifyObject ( int TypeID , ULONG code );
*
* --- Lokale Routinen ---
*
* static BOOL CheckObject ( struct List *list , struct objectid *obj );
* static BOOL CheckTask ( struct objectid *obj );
* static int CheckScreen ( struct Screen *findscr );
* static int OpenChgPriWindow ( void );
* static struct MsgPort *TaskPort ( struct Task *task );
* static struct Window *TaskWindow ( struct Task *task );
* static void ChangePri ( struct objectid *obj );
* static void ClosingScreens ( struct Screen *scr );
* static void ClosingWindows ( struct Window *wind );
* static void DisplayAllFonts ( int TypeID , struct Node *ClickedNode );
* static void DisplayResource ( int TypeID , struct objectid *obj );
* static void DisplaySoftDevice ( int TypeID , struct objectid *obj );
* static void DisplayTreeDevice ( int TypeID , struct objectid *obj );
* static void FlushLibrary ( struct objectid *obj );
* static void KillTask ( struct objectid *obj );
* static void ModifyFont ( int TypeID , struct objectid *obj );
* static void ModifyLibrary ( int TypeID , struct objectid *obj );
* static void ModifyPort ( int TypeID , struct objectid *obj );
* static void ModifyScreen ( int TypeID , struct objectid *obj );
* static void ModifyTask ( int TypeID , struct objectid *obj );
* static void ModifyVolumeLock ( int TypeID , struct objectid *obj );
* static void ModifyWindow ( int TypeID , struct objectid *obj );
* static void RemoveFontSafely ( struct TextFont *tf );
* static void RemovePortSafely ( struct MsgPort *p , struct objectid *obj );
* static void SignalTask ( struct objectid *obj , ULONG signal );
*
* Bemerkungen:
* Enthält die Routinen zum Modifizieren von Objekten.
*
* Erstellungsdatum:
* 07-Jan-93 Rolf Böhme
*
* Änderungen:
* 07-Jan-93 Rolf Böhme Erstellung
*
***************************************************************************
*/
#include "RSys.h"
static void KillTask(struct objectid *);
static int modified = FALSE;
/*
* CheckObject() prüft, ob ein ausgewähltes Listenelement (Objekt)
* sich noch in der Liste befindet
*/
static BOOL
CheckObject(struct List *list, struct objectid *obj)
{
struct Node *node;
Forbid();
for (node = list->lh_Head; node->ln_Succ && (node != obj->address); node = node->ln_Succ) ;
Permit();
return ((node == obj->address) ? TRUE : FALSE);
}
/*
* CheckTask() prüft, ob ein Task-Objekt sich noch in den Listen
* befindet, also noch existiert
*/
static BOOL
CheckTask(struct objectid *obj)
{
if(CheckObject(&(SysBase->TaskWait),obj) || CheckObject(&(SysBase->TaskReady),obj) ||
((struct Task *)obj->address == FindTask(NULL)))
return(TRUE);
else return(FALSE);
}
/*
* CountAssocObjects() zählt die zu einem Task gehörenden
* Windows, Screens und Ports
*/
void
CountAssocObjects(struct Task *task, int *wins, int *scrs, int *ports)
{
ULONG lock;
struct Window *win;
struct Screen *scr;
struct MsgPort *port;
struct Node *node;
DPOS;
Forbid();
lock = LockIBase(NULL);
for (scr = IntuitionBase->FirstScreen; scr; scr = scr->NextScreen)
for (win = scr->FirstWindow; win; win = win->NextWindow)
{
if (win->UserPort && win->UserPort->mp_SigTask &&
(win->UserPort->mp_SigTask == task))
{
(*wins)++;
if ((scr->Flags & CUSTOMSCREEN) && NOT(scr->Flags & PUBLICSCREEN))
(*scrs)++;
}
}
UnlockIBase(lock);
for (node = SysBase->PortList.lh_Head; node->ln_Succ; node = node->ln_Succ)
{
port = (struct MsgPort *) node;
if (port->mp_SigTask && (port->mp_SigTask == task))
(*ports)++;
}
Permit();
return;
}
/*
* CheckWindow() prüft, ob ein Fenster noch existiert, und zwar
* auf allen Screens
*/
int
CheckWindow(struct Window *findwin)
{
ULONG lock;
struct Window *win;
struct Screen *scr;
int ret = FALSE;
DPOS;
lock = LockIBase(NULL);
for (scr = IntuitionBase->FirstScreen; scr && NOT(ret); scr = scr->NextScreen)
for (win = scr->FirstWindow; win && NOT(ret); win = win->NextWindow)
if (win == findwin) ret = TRUE;
UnlockIBase(lock);
return ret;
}
/*
* CheckScreen() prüft, ob ein Screen noch existiert
*/
static int
CheckScreen(struct Screen *findscr)
{
ULONG lock;
struct Screen *scr;
int ret = FALSE;
lock = LockIBase(NULL);
for (scr = IntuitionBase->FirstScreen; scr && NOT(ret); scr = scr->NextScreen)
if (scr == findscr) ret = TRUE;
UnlockIBase(lock);
return ret;
}
/*
* TaskPort() sucht in der Liste der öffentlichen Ports
* nach dem ersten Port, der den Task task als Signaltask
* hat
*/
static struct MsgPort *
TaskPort(struct Task *task)
{
struct MsgPort *taskport = NULL,
*port;
struct Node *node;
Forbid();
for (node = SysBase->PortList.lh_Head; node->ln_Succ; node = node->ln_Succ)
{
port = (struct MsgPort *) node;
if (port->mp_SigTask && (port->mp_SigTask == task))
{
taskport = port;
break;
}
}
Permit();
return taskport;
}
/*
* TaskWindow() sucht in der IntuitionBase nach dem ersten Fenster,
* dessen UserPort zu dem Task task gehört
*/
static struct Window *
TaskWindow(struct Task *task)
{
ULONG lock;
struct Window *win,
*taskwindow = NULL;
struct Screen *scr;
lock = LockIBase(NULL);
for (scr = IntuitionBase->FirstScreen; scr && NOT(taskwindow); scr = scr->NextScreen)
for (win = scr->FirstWindow; win && NOT(taskwindow); win = win->NextWindow)
if (win->UserPort && (win->UserPort->mp_SigTask) && (win->UserPort->mp_SigTask == task))
taskwindow = win;
UnlockIBase(lock);
return taskwindow;
}
/*
* ClosingWindows() schließt ein Fenster auf sicherste
* Weise, wie ich hoffe...
*/
static void
ClosingWindows(struct Window *wind)
{
if (CheckWindow(wind))
{
if((wind->ReqCount != 0) && wind->FirstRequest)
while(wind->ReqCount != 0) EndRequest(wind->FirstRequest,wind);
if(wind->DMRequest) ClearDMRequest(wind);
if(wind->Pointer) ClearPointer(wind);
if(wind->MenuStrip) ClearMenuStrip(wind);
CloseWindow(wind);
}
else ErrorHandle("CheckWindow()", WINDOW_ERR, FIND_FAIL, NO_KILL);
return;
}
/*
* ClosingScreens() schließt einen Screen auf sicherste
* Weise, wie ich hoffe...
*/
static void
ClosingScreens(struct Screen *scr)
{
struct Window *win = scr->FirstWindow,
*markwin;
if (CheckScreen(scr))
{
while (win)
{
markwin = win->NextWindow;
ClosingWindows(win);
win = markwin;
}
CloseScreen(scr);
if (CheckScreen(scr)) PrintInfo("Screen not killed!", SPEAK, SEC);
}
else ErrorHandle("CheckScreen", SCREEN_ERR, FIND_FAIL, NO_KILL);
return;
}
/*
* RemovePortSavely() entfernt eine Port auf sicherste Weise
*/
static void
RemovePortSafely(struct MsgPort *p, struct objectid *obj)
{
struct Node *MsgNode;
struct MsgPort *port;
port = (obj ? (struct MsgPort *) obj->address : p);
Forbid();
if (NOT(IsMsgPortEmpty(port)))
{
MsgNode = port->mp_MsgList.lh_Head;
while (MsgNode = MsgNode->ln_Succ)
Remove((struct Node *) MsgNode);
}
DeletePort(port);
if (CheckObject(&SysBase->PortList, obj))
RemPort(port);
Permit();
return;
}
static void
RemoveFontSafely(struct TextFont *tf)
{
if (tf->tf_Flags & FPF_DISKFONT)
{
Forbid();
CloseFont(tf);
Remove((struct Node *) tf);
Permit();
}
else if (Question(SysWnd,"You attempt to remove a ROM-Font!\n"
"Remove this Font anyway?", YES))
{
Forbid();
RemFont(tf);
Remove((struct Node *) tf);
Permit();
}
return;
}
/*
* KillTask() entfernt einen Task aund alle mit ihm verbundenen
* Windows, Screens und Ports. Alle anderen Resourcen können
* nicht mehr eindeutig zugeordnet werden
*/
static void
KillTask(struct objectid *obj)
{
struct Task *task = (struct Task *) obj->address;
struct Window *taskwin;
struct MsgPort *port;
if (Question(SysWnd, "Break signal failed!\n"
"Do you really want to kill the task harder?", YES))
if (CheckTask(obj))
{
Forbid();
Disable();
Remove((struct Node *)task);
Enable();
if (taskwin = TaskWindow(task))
{
struct Screen *taskscr = NULL;
ULONG lock = LockIBase(NULL);
if (taskwin->WScreen && (taskwin->WScreen->Flags & CUSTOMSCREEN))
taskscr = taskwin->WScreen;
while (taskwin)
{
ClosingWindows(taskwin);
taskwin = TaskWindow(task);
}
if (taskscr) CloseScreen(taskscr);
UnlockIBase(lock);
}
while(port = TaskPort(obj->address)) RemovePortSafely(port, NULL);
Disable();
RemTask(task);
Enable();
Permit();
}
else ErrorHandle("CheckTask()", TASK_ERR, FIND_FAIL, NO_KILL);
return;
}
/*
* SignalTask() sendet eine Signal signal an den Task obj
*/
static void
SignalTask(struct objectid *obj, ULONG signal)
{
struct Task *task;
if (task = FindTask((UBYTE *) obj->fullname)) Signal(task, signal);
else
ErrorHandle(obj->fullname, TASK_ERR, FIND_FAIL, NO_KILL);
return;
}
static struct Window *ChgPriWnd = NULL;
static struct Gadget *ChgPriGList = NULL;
static struct Gadget *ChgPriGadgets[5];
static UWORD ChgPriLeft = 195;
static UWORD ChgPriTop = 71;
static UWORD ChgPriWidth = 228;
static UWORD ChgPriHeight = 55;
static UBYTE *ChgPriWdt = (UBYTE *) NAME " " VERSION " - Change priority";
static UWORD ChgPriGTypes[]=
{
TEXT_KIND,
SLIDER_KIND,
BUTTON_KIND,
BUTTON_KIND,
INTEGER_KIND
};
static struct NewGadget ChgPriNGad[]=
{
52, 5, 169, 13, (UBYTE *) "Task", NULL, GD_TaskGad, PLACETEXT_LEFT, NULL, NULL,
52, 21, 129, 13, (UBYTE *) "Prio", NULL, GD_PrioGad, NG_HIGHLABEL, NULL, NULL,
8, 37, 69, 13, (UBYTE *) "Ok", NULL, GD_OkGad, PLACETEXT_IN, NULL, NULL,
156, 37, 65, 13, (UBYTE *) "Cancel", NULL, GD_CancelPriGad, PLACETEXT_IN, NULL, NULL,
88, 37, 57, 13, NULL, NULL, GD_PriIntGad, 0, NULL, NULL
};
static ULONG *ChgPriGTags[]=
{
(ULONG *) (GTTX_Text), (ULONG *) NULL,
(ULONG *) (GTTX_Border), (ULONG *) TRUE,
(ULONG *) (TAG_DONE),
(ULONG *) (GTSL_Min), (ULONG *) (-128),
(ULONG *) (GTSL_Max), (ULONG *) 128,
(ULONG *) (GTSL_MaxLevelLen), (ULONG *) 4,
(ULONG *) (GTSL_LevelFormat), (ULONG *) "%4ld",
(ULONG *) (GTSL_LevelPlace), (ULONG *) (PLACETEXT_RIGHT),
(ULONG *) (PGA_Freedom), (ULONG *) LORIENT_HORIZ,
(ULONG *) (GA_Immediate), (ULONG *) TRUE,
(ULONG *) (GA_RelVerify), (ULONG *) TRUE,
(ULONG *) (TAG_DONE),
(ULONG *) (TAG_DONE),
(ULONG *) (TAG_DONE),
(ULONG *) (GTIN_Number), (ULONG *) 0,
(ULONG *) (GTIN_MaxChars), (ULONG *) 5,
(ULONG *) (TAG_DONE)
};
/*
* OpenChgPriWindow() öffnet ein kleines Fenster, in
* dem man mit einem Slider die Priorität eines Tasks einstellen
* kann
*/
static int
OpenChgPriWindow(void)
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc,
tc;
UWORD wleft = ChgPriLeft,
wtop = ChgPriTop,
ww,
wh;
int gl[] = {GD_TaskGad - GD_TaskGad,
GD_PriIntGad - GD_TaskGad,
GD_PrioGad - GD_TaskGad};
AdjustWindowDimensions(Scr, ChgPriLeft, ChgPriTop, ChgPriWidth, ChgPriHeight,
&wleft, &wtop, &ww, &wh);
if (!(g = CreateContext(&ChgPriGList))) return 1L;
for (lc = 0, tc = 0; lc < ChgPri_CNT; lc++)
{
CopyMem((char *)&ChgPriNGad[lc], (char *)&ng, (long)sizeof(struct NewGadget));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX(ng.ng_LeftEdge);
ng.ng_TopEdge = OffY + ComputeY(ng.ng_TopEdge);
ng.ng_Width = ComputeX(ng.ng_Width);
ng.ng_Height = ComputeY(ng.ng_Height);
ChgPriGadgets[lc] = g = CreateGadgetA((ULONG) ChgPriGTypes[lc], g, &ng, (struct TagItem *) & ChgPriGTags[tc]);
makelabelvisible(ChgPriGadgets[lc]);
while (ChgPriGTags[tc]) tc += 2;
tc++;
if (NOT g) return 2L;
}
if (!(ChgPriWnd = OpenWindowTags(NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww,
WA_Height, wh,
WA_IDCMP, TEXTIDCMP |
SLIDERIDCMP |
BUTTONIDCMP |
INTEGERIDCMP |
IDCMP_CLOSEWINDOW |
IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR |
WFLG_DEPTHGADGET |
WFLG_CLOSEGADGET |
WFLG_SMART_REFRESH |
WFLG_ACTIVATE |
WFLG_RMBTRAP,
WA_Title, ChgPriWdt,
WA_PubScreenFallBack,TRUE,
WA_PubScreen, Scr,
TAG_DONE)))
return 4L;
RefreshRastPort(ChgPriWnd,ChgPriGadgets,gl, 3, FALSE, ChgPriGList);
return (0L);
}
/*
* ChangePri() öffnet ein Fenster und managed das
* Priority-Handling für ein gewähltes Objekt obj
*/
static void
ChangePri(struct objectid *obj)
{
struct Task *task = (struct Task *) obj->address;
int TaskPri = task->tc_Node.ln_Pri,
OldPri = TaskPri;
register struct IntuiMessage *message;
ULONG class,
code;
APTR object;
extern struct Window *ChgPriWnd;
extern struct Gadget *ChgPriGadgets[];
Flags.quit_cp = 0;
if (OpenASysWindow(OpenChgPriWindow,NO_KILL))
{
LockMainWindow(LOCK);
GT_SetGadgetAttrs(ChgPriGadgets[GD_TaskGad - GD_TaskGad], ChgPriWnd, NULL,
GTTX_Text, (UBYTE *) obj->fullname,
TAG_DONE);
GT_SetGadgetAttrs(ChgPriGadgets[GD_PrioGad - GD_TaskGad], ChgPriWnd, NULL,
GTSL_Level, (UBYTE *) TaskPri,
TAG_DONE);
GT_SetGadgetAttrs(ChgPriGadgets[GD_PriIntGad - GD_TaskGad], ChgPriWnd, NULL,
GTIN_Number, (UBYTE *) TaskPri,
TAG_DONE);
do
{
Wait(1L << ChgPriWnd->UserPort->mp_SigBit);
while ((message = (struct IntuiMessage *)
GT_GetIMsg(ChgPriWnd->UserPort)) != NULL)
{
object = message->IAddress;
class = message->Class;
code = message->Code;
GT_ReplyIMsg(message);
switch (class)
{
case IDCMP_GADGETUP:
switch (((struct Gadget *) object)->GadgetID)
{
case GD_PrioGad:
TaskPri = (int)((char)code);
GT_SetGadgetAttrs(ChgPriGadgets[GD_PriIntGad - GD_TaskGad], ChgPriWnd,
NULL,
GTIN_Number, (int)TaskPri,
TAG_DONE);
break;
case GD_OkGad:
Flags.quit_cp = 1;
break;
case GD_CancelPriGad:
TaskPri = OldPri;
Flags.quit_cp = 1;
break;
case GD_PriIntGad:
TaskPri = (int)((struct StringInfo *)
(((struct Gadget *)
object)->SpecialInfo))->LongInt;
if ((TaskPri < -128) || (TaskPri > 127))
GT_SetGadgetAttrs(ChgPriGadgets[GD_PriIntGad - GD_TaskGad],
ChgPriWnd,
NULL,
GTIN_Number, OldPri,
TAG_DONE);
else
GT_SetGadgetAttrs(ChgPriGadgets[GD_PrioGad - GD_TaskGad], ChgPriWnd,
NULL,
GTSL_Level, TaskPri,
TAG_DONE);
break;
}
break;
case IDCMP_CLOSEWINDOW:
TaskPri = OldPri;
Flags.quit_cp = 1;
break;
}
}
}
while (NOT(Flags.quit_cp));
CloseASysWindow(&ChgPriWnd, &ChgPriGList, NULL);
if (CheckTask(obj) && (TaskPri != OldPri)) SetTaskPri(task, TaskPri);
LockMainWindow(UNLOCK);
}
return;
}
/*
* FlushLibrary() entfernt eine geschlossene Library aus
* dem System
*/
static void
FlushLibrary(struct objectid *obj)
{
struct Library *result;
if (Question(SysWnd, "Do you really want to remove the Library?", YES))
{
Forbid();
result = (struct Library *)FindName(&SysBase->LibList, (UBYTE *)obj->fullname);
if (result && (result->lib_OpenCnt == 0)) RemLibrary(result);
Permit();
if (!result) ErrorHandle(obj->fullname, LIBRARY_ERR, FIND_FAIL, NO_KILL);
}
return;
}
static void
ModifyTask(int TypeID, struct objectid *obj)
{
WORD sel;
ULONG signals[5] =
{
SIGBREAKF_CTRL_C, SIGBREAKF_CTRL_D, SIGBREAKF_CTRL_E, SIGBREAKF_CTRL_F,
(SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D | SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F)
};
if (CheckTask(obj))
{
sel = DisplayTaskInfo(obj);
switch (sel)
{
case 1:
if (obj->address != FindTask(NULL))
{
SignalTask(obj, signals[4]);
Delay(SEC);
if (CheckTask(obj)) KillTask(obj);
else
PrintInfo("Break signal killed the task!", SPEAK, 2*SEC);
modified = TRUE;
}
else ErrorHandle(obj->fullname, OWN_OBJECT_ERR, KILL_FAIL, NO_KILL);
break;
case 0:
break;
case 2:
case 3:
case 4:
case 5:
SignalTask(obj, signals[sel - 2]);
modified = TRUE;
break;
case 6:
if (CheckTask(obj)) ChangePri(obj);
else
ErrorHandle(obj->fullname, TASK_ERR, FIND_FAIL, NO_KILL);
modified = TRUE;
break;
case 7:
modified = TRUE;
break;
}
return;
}
else ErrorHandle(obj->fullname, TASK_ERR, FIND_FAIL, NO_KILL);
modified = TRUE;
return;
}
static void
ModifyLibrary(int TypeID, struct objectid *obj)
{
if (CheckObject(&SysBase->LibList, obj))
{
if(DisplayLibraryInfo(obj)) FlushLibrary(obj);
}
else ErrorHandle(obj->fullname, LIBRARY_ERR, FIND_FAIL, NO_KILL);
modified = TRUE;
return;
}
static void
DisplaySoftDevice(int TypeID, struct objectid *obj)
{
if (CheckObject(&SysBase->DeviceList, obj)) DisplaySoftDevInfo(obj);
else
{
ErrorHandle("Soft Device", DEVICE_ERR, FIND_FAIL, NO_KILL);
modified = TRUE;
}
return;
}
static void
DisplayResource(int TypeID, struct objectid *obj)
{
if (CheckObject(&SysBase->ResourceList, obj))
DisplayResourceInfo(obj);
else
{
ErrorHandle("Resource", DEVICE_ERR, FIND_FAIL, NO_KILL);
modified = TRUE;
}
return;
}
static void
ModifyPort(int TypeID, struct objectid *obj)
{
WORD sel;
if (CheckObject(&SysBase->PortList, obj))
{
sel = DisplayPortInfo(obj);
if (sel && ((obj->address == SysIdPort) || (obj->address == broker_mp) ||
(strstr(obj->fullname,"RSYS") != NULL)))
{
ErrorHandle(obj->fullname, OWN_OBJECT_ERR, MODIFY_FAIL, NO_KILL);
return;
}
if (sel && Question(SysWnd, "Do you want to remove the Port?", YES))
{
if (CheckObject(&SysBase->PortList, obj)) RemovePortSafely(NULL, obj);
else
ErrorHandle(obj->fullname, PORT_ERR, FIND_FAIL, NO_KILL);
modified = TRUE;
}
}
else
{
ErrorHandle(obj->fullname, PORT_ERR, FIND_FAIL, NO_KILL);
modified = TRUE;
}
return;
}
static void
ModifyFont(int TypeID, struct objectid *obj)
{
WORD sel;
struct TextFont *tf = (struct TextFont *) obj->address;
if (CheckObject(&GfxBase->TextFonts, obj)) sel = DisplayFontInfo(obj);
else
{
ErrorHandle(obj->fullname, FONT_ERR, FIND_FAIL, NO_KILL);
modified = TRUE;
return;
}
switch(sel)
{
case 1:
if (Question(SysWnd, "Do you want to close and remove this font?", YES))
{
if (CheckObject(&GfxBase->TextFonts, obj)) RemoveFontSafely(tf);
else
ErrorHandle(obj->fullname, FONT_ERR, FIND_FAIL, NO_KILL);
modified = TRUE;
}
break;
case 2:
if (CheckObject(&GfxBase->TextFonts, obj)) ShowFont((struct TextFont *) obj->address);
else
{
ErrorHandle(obj->fullname, FONT_ERR, FIND_FAIL, NO_KILL);
modified = TRUE;
}
break;
}
return;
}
static void
ModifyWindow(int TypeID, struct objectid *obj)
{
WORD sel;
sel = DisplayWindowInfo(obj);
if (sel && ((struct Window *) obj->address == SysWnd))
{
ErrorHandle("Main window", OWN_OBJECT_ERR, MODIFY_FAIL, NO_KILL);
return;
}
if (sel &&Question(SysWnd, "Closing of Windows are very dangerous! The System \n"
"may be crash, when you close an active Window\n"
"Do you want to close the Window anyway?", YES))
ClosingWindows((struct Window *) obj->address);
modified = TRUE;
return;
}
static void
ModifyScreen(int TypeID, struct objectid *obj)
{
WORD sel;
sel = DisplayScreenInfo(obj);
if (sel && (((struct Screen *) obj->address == SysWnd->WScreen) ||
(((struct Screen *) obj->address)->Flags & WBENCHSCREEN)))
{
ErrorHandle((char *)namebuffer, OWN_OBJECT_ERR, MODIFY_FAIL, NO_KILL);
return;
}
if (sel && Question(SysWnd, "Closing of Screens are very dangerous! The System \n"
"may be crash, when you close an active Screen with\n"
"all associated windows!\n"
"Do you want to close the Screen and Windows anyway?", YES))
{
ClosingScreens((struct Screen *) obj->address);
modified = TRUE;
}
return;
}
static void
DisplayTreeDevice(int TypeID, struct objectid *obj)
{
if (DisplayDiskInfo(obj->fullname, TRUE)) PrintTree(obj);
return;
}
static void
DisplayAllFonts(int TypeID, struct Node *ClickedNode)
{
struct TextFont *tf;
struct TextAttr testfont;
int i,
j;
char fontname[MAXSTRLEN],
size[5];
i = 0;
while (ClickedNode->ln_Name[i] != ' ')
{
fontname[i] = ClickedNode->ln_Name[i];
i++;
}
fontname[i] = STRINGEND;
testfont.ta_Name = (UBYTE *) fontname;
while (ClickedNode->ln_Name[i] == ' ') i++;
while (ClickedNode->ln_Name[i] != ' ') i++;
while (ClickedNode->ln_Name[i] == ' ') i++;
j = 0;
while (ClickedNode->ln_Name[i] != ' ')
{
size[j] = ClickedNode->ln_Name[i];
i++;
j++;
}
size[j] = STRINGEND;
testfont.ta_YSize = atoi(size);
testfont.ta_Flags = 0;
testfont.ta_Style = 0;
tf = OpenDiskFont(&testfont);
if (tf)
{
ShowFont(tf);
CloseFont(tf);
}
return;
}
static void
ModifyVolumeLock(int TypeID, struct objectid *obj)
{
if(DisplayLockInfo(obj) && Question(SysWnd, "Unlocking is very dangerous!\n"
"Do you really want to unlock this lock?",YES))
{
Forbid();
UnLock((BPTR)obj->address);
Permit();
modified = TRUE;
}
return;
}
/*
* ModifyObject() prüft ob ein Element einer Liste im Hauptfenster
* modifiziert oder angezeigt werden kann und ruft die entsprechenden
* Routinen auf
*/
void
ModifyObject(int TypeID, ULONG code)
{
struct Node *ClickedNode;
struct objectid *obj;
char out[BUFSIZE]
DPOS;
modified = FALSE;
sprintf(out, "Modify %s", EntryAttr[TypeID].ea_type);
PrintInfo(out, SPEAK, 0);
if (NOT(ClickedNode = GetNode(&ListeLVList, code)))
{
ErrorHandle("No Object found ???", LIST_NODE_ERR, FIND_FAIL, NO_KILL);
return;
}
obj = &((ScrollEntry *) ClickedNode)->se_obj_id;
switch (TypeID)
{
case TASKS:
ModifyTask(TypeID, obj);
break;
case LIBRARIES:
ModifyLibrary(TypeID, obj);
break;
case SYSSOFTDEV:
DisplaySoftDevice(TypeID, obj);
break;
case RESOURCES:
DisplayResource(TypeID, obj);
break;
case PORTS:
ModifyPort(TypeID, obj);
break;
case FONTS:
ModifyFont(TypeID, obj);
break;
case WINDOWS:
ModifyWindow(TypeID, obj);
break;
case SCREENS:
ModifyScreen(TypeID, obj);
break;
case ASSIGNS:
case VOLUMES:
DisplayTreeDevice(TypeID, obj);
break;
case ALLFONTS:
DisplayAllFonts(TypeID, ClickedNode);
break;
case VOLLOCKS:
ModifyVolumeLock(TypeID, obj);
break;
case SYSINFO:
case HARDWARE:
case PREFS:
case ENVVARS:
case SYSVECTORS:
case PRINTERDATA:
case LIBRARYOFFS:
DisplayBeep(NULL);
break;
case MEMORY:
if(code < 3) DisplayBeep(NULL);
else
Monitor(obj, ((ScrollEntry *) ClickedNode)->se_Entry);
break;
default:
Monitor(obj, ((ScrollEntry *) ClickedNode)->se_Entry);
break;
}
if(modified) RefreshList(LastID);
PrintStatistics();
return;
}